package day06;

import java.util.Scanner;

public class DayHomeWork06Practice2 {
    public static void main(String[] args) {
        double[] scores = inputData(7);
        double avg = calAvg(scores);
        System.out.println("平均分为："+avg);
    }
    public static double[] inputData(int n) {
        double[] scores = new double[n];
        Scanner scan = new Scanner(System.in);
        for (int i = 0; i < scores.length; ++i) {
            System.out.println("请输入评委的分数：");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }

    public static double calAvg(double[] scores) {
        double avg=0.0;
        double max = scores[0], min = scores[0];
        for (double score : scores) {
            if (score > max) {
                max = score;
            }
            if (score < min) {
                min = score;
            }
            avg += score;
        }
        avg = (avg - min - max) / (scores.length - 2);
        return avg;
    }

}
